<?php
	require_once("../conexion/conexion.php");
	$rut = $_POST['rut'];
	$mes = $_POST['mes'];
	$agno = date('Y');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />

<script src="../include_js/jquery.js" type="text/javascript"></script>

<style>
.texto
{
	font-size:14px;
	margin-left:10px;
	font:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC;
}
.borde
{
	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
.asterisco
{
	color:#0000FF;
	font-weight:bold;
}
.radioBorde
{ 
 background:#D3E4E5;
 border:0px solid #89C0C7;
}
.filaPar
{
	background:#81D371; 
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
.filaImpar
{
	background:#AEF1A1;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
</style>
<script>
function Prestamo(valor)
{
	document.getElementById('txtPrestamo').value = (valor-1);
}
</script>
</head>

<body>

  <?php
  	$con = new Conexion();
	$con2 = $con->conexionBD("fpproduccion");
	$sql = "select 
				EmpPresNumCuota,
				EmpPresMonto,
				PresMonto,
				empprestamo.PresCod as cod
				from empprestamo
				inner join prestamo on
				empprestamo.PresCod=prestamo.PresCod
				where (EmpRut='".$rut."' and month(EmpPresFecha)='".$mes."' and year(EmpPresFecha)='".$agno."' and EmpPresEstado='PENDIENTE')";
	$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$fila = mysql_num_rows($res);
	//echo $fila;
	if($fila >0)
	{?>
	<table width="100%" border="0" cellpadding="0">
  	<tr>
    	<td class="borde"><label class="texto" style="font-weight:bold;">Prestamo.</label></td>
  	</tr>
	<tr><td class="borde">&nbsp;</td></tr>
	</table>
	<div style="margin-left:35px">
		<table width="248" border="0" cellpadding="0" cellspacing="0" class="uno">
		<thead>
		<tr>
			<th>id</th>
			<th width="74">n&deg; cuota</th>
			<th width="80">monto ($)</th>
			<th width="92">Prestamo ($)</th>
		</tr>
		</thead>
		<?php
		$cont = 1;
			while($reg = mysql_fetch_array($res))
			{
				echo "<tr>";
				echo "<td><input type='text' readonly='true' name='txtID"."$cont' size='1' style='text-align:center;background:#E1E1E1' value='".$reg['cod']."' /></td>";
				echo "<td width='74'><input type='text' readonly='true' name='txtNumCuota"."$cont' size='12' style='text-align:center;background:#E1E1E1' value='".$reg['EmpPresNumCuota']."' /></td>";
				echo "<td width='80'><input type='text' readonly='true' name='txtMontoCuota"."$cont' size='15' style='text-align:center;background:#E1E1E1;' value='".number_format ($reg['EmpPresMonto'],0,',','.')."'/></td>";
				echo "<td width='92'><input type='text' readonly='true' name='txtMontoPrestamo"."$cont' size='15' style='text-align:center;background:#E1E1E1;' value='".number_format ($reg['PresMonto'],0,',','.')."'/></td>";
				echo "</tr>";
				$cont++;
			}
			echo "<script>Prestamo('$cont');</script>";
			?>
	  </table></div>
			<table width="100%" border="0" cellpadding="0">
  				<tr><td class="borde"><hr /></td></tr>
			</table>
  	</tr>
	<?php 
	}
	else
	{echo "<script>Prestamo(1);</script>";}
	?>
</body>
</html>
